﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AltF4Sender
{
    public static class Program
    {
        public const string type = "altf4";

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.Sleep(100);
            keybd_event(Keys.LWin, 0, 0, 0);

            Thread.Sleep(50);
            keybd_event(Keys.G, 0, 0, 0);
            Thread.Sleep(150);
            keybd_event(Keys.G, 0, KEYEVENTF_KEYUP, 0);

            Thread.Sleep(50);
            keybd_event(Keys.LWin, 0, KEYEVENTF_KEYUP, 0);

            Thread.Sleep(500);
            keybd_event(Keys.LMenu, 0, 0, 0);

            Thread.Sleep(50);
            keybd_event(Keys.F4, 0, 0, 0);
            Thread.Sleep(150);
            keybd_event(Keys.F4, 0, KEYEVENTF_KEYUP, 0);

            Thread.Sleep(50);
            keybd_event(Keys.LMenu, 0, KEYEVENTF_KEYUP, 0);
        }
        public const int KEYEVENTF_KEYUP = 2;
        [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true)]
        public static extern void keybd_event(Keys bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
    }
}
